package csu.rjxyg.action.infoAction;

import java.util.List;

import csu.rjxyg.action.BaseAction;
import csu.rjxyg.action.constant.InfoConstant;
import csu.rjxyg.action.constant.UserConstant;
import csu.rjxyg.bean.core.BaseList;
import csu.rjxyg.bean.core.BaseObject;
import csu.rjxyg.factory.core.UtilFactory;
import csu.rjxyg.service.BaseInfoService;
import csu.rjxyg.util.LogUtil;

public class GetNotReadInfoNumberAction  extends BaseAction{
	private LogUtil log;	
	
	public GetNotReadInfoNumberAction(){
		log = UtilFactory.getLogUtil(this.getClass());
	}
	
	public void getNumber(){
		String name = null;
		try{
			BaseObject object = (BaseObject) this.getSession().get(UserConstant.USER_SESSION);
			name = (String) object.get(UserConstant.USER_ID);
			List acceptList =  (List) object.get(UserConstant.USER_ACCEPT_INFO);
			BaseList temp = null;
			int number = 0;
			if(acceptList != null){
				BaseInfoService baseInfoService = (BaseInfoService) factory.getBean(INFO_SERVICE);
				temp = baseInfoService.getAllInfoById(acceptList, 3);
				for( int i = 0;i < temp.size();i++ ){
					if( temp.get(i).get(InfoConstant.INFO_STATUS).equals("未读")){
						number++;
					}
				}
			}
			
			
			this.out(number + "");
			log.info(name + "查询未读邮件数目成功");
		}catch(Exception e){
			log.info(name + "查询未读邮件数目失败");
			e.printStackTrace();
			log.info(e.getMessage());
		}
	}
}
